/**
 * 如果 A 是类，B 是接口，并且 A 类实现了 B 接口
 * 跟第一种情况相同
 */

interface People {
  username: string;
  age: number;
  address: string;
}

//  Stu实现了People的接口
class Stu implements People {
  public username!: string;
  public age!: number;
  public address!: string;
  public phone!: string;
  constructor(username: string, age: number, address: string) {
    this.username = username;
    this.age = age;
    this.address = address;
  }
  public study() {
    console.log("我在学习",this.address);
  }
}

let people:People = {
  username:'wange',
  age:12,
  address:'上海'
}

let stu = new Stu('wsl',14,'北京');

let result = people as Stu;// ! 类型断言  stu是实现了People的 所以断言成功
// result.study()//! 失败 因为people里面没有study

stu as People; // ! 可以断言成功
stu.study();
// let result = <Stu>people; // 类型断言语法

export {};
